<?php
/**
 * 中轩首页模块system_welcome接口定义
 *
 * @author zhongxuan
 * @url http://bbs.we7.cc
 */
defined('IN_IA') or exit('Access Denied');
	
class Zh_shouye1ModuleSystemWelcome extends WeModuleSystemWelcome {
	public function systemWelcomeDisplay() {
		// 此处开发者自行处理
		global $_W, $_GPC;
		
		//获取公司与站点配置信息
		$domain=$_SERVER['HTTP_HOST'];//域名
		$site_code=pdo_getcolumn('index_sys_site', array('site_domain' =>$domain), 'site_code');//标识
		$config_list=pdo_getall('index_sys_config',array('status'=>1,'site_code'=>$site_code));
		$config_row=array();
		foreach ($config_list as &$conf){
			$config_row[$conf['config_code']]=$conf['config_value'];
		}
		
		//轮播图
		$ad_list=pdo_getall('index_cms_ad',array('is_show'=>1));
		//友链
		$link_list=pdo_getall('index_mis_friendlink');
		
		
		$operate=$_GPC['page'];
		if(!$operate){
			$operate='index';
		}
		switch ($operate) {
			case 'index'://首页
				//banner
				//第一个id=5
				$site1=pdo_get('index_banner_site',array('site_id'=>5));
				$banner1_list=pdo_getall('index_banner',array('banner_site'=>5));
				//第二个id=6 新闻 
				$site_news=pdo_get('index_banner_site',array('site_id'=>6));
				//$banner2_list=pdo_getall('index_banner',array('banner_site'=>6));
				//第三二个id=7
				//$site3=pdo_get('index_banner_site',array('site_id'=>7));
				//$banner3_list=pdo_getall('index_banner',array('banner_site'=>7));
				//第四个id=8
				//$site4=pdo_get('index_banner_site',array('site_id'=>8));
				//$banner4_list=pdo_getall('index_banner',array('banner_site'=>8));
				//第五个id=9
				$site5=pdo_get('index_banner_site',array('site_id'=>9));
				$banner5_list=pdo_getall('index_banner',array('banner_site'=>9));
				//第6个id=4   产品中心
				$site_product=pdo_get('index_banner_site',array('site_id'=>4));
				//第7个id=3   案例中心
				$site_case=pdo_get('index_banner_site',array('site_id'=>3));
				
				
				//产品中心取前六条数据
				$product_list=pdo_fetchall("select * from ".tablename('index_mis_product')." where is_show=1 order by product_id desc limit 0,8");
				//新闻动态
				$article_list=pdo_fetchall("select * from ".tablename('index_cms_article')."  where is_show=1 order by article_sort desc limit 0,10");
				//案例中心
				$case_list=pdo_fetchall("select * from ".tablename('index_mis_case')."  where is_show=1 order by add_time desc limit 0,10");
				
			;
			include $this->template('index/index');
			break;
			case 'product'://应用
				$site_product=pdo_get('index_banner_site',array('site_id'=>4));
				$product_list=pdo_fetchall("select * from ".tablename('index_mis_product')." where is_show=1 order by product_id desc");
				include $this->template('index/list_product');
			;
			break;
			case 'case'://案例
			$site_case=pdo_get('index_banner_site',array('site_id'=>3));
				$case_list=pdo_fetchall("select * from ".tablename('index_mis_case')." where is_show=1 order by case_id desc");
				include $this->template('index/list_case');
			;
			break;
			case 'jiameng'://加盟
			;
			break;
			case 'about'://首页关于我们
				
				include $this->template('index/page_about');
			;
			break;
			case 'news'://动态
				
				$cat_list=pdo_fetchall("select * from ".tablename('index_cms_category')." order by cat_sort desc");
				if(!empty($_GPC['article_id'])){
					$article=pdo_get('index_cms_article',array('article_id'=>$_GPC['article_id']));
					include $this->template('index/show_news');
				}else{
					$article_list=pdo_fetchall("select * from ".tablename('index_cms_article')."  where is_show=1 order by article_id desc");
					if(!empty($_GPC['cat_id'])){
						$sql="select * from ".tablename('index_cms_article')." where article_cat=".$_GPC['cat_id']." and is_show=1 order by article_id desc";
					}else{
						$sql="select * from ".tablename('index_cms_article')." where is_show=1 order by article_sort desc";
						$_GPC['cat_id']='all';
					}
					$article_list=pdo_fetchall($sql);
					include $this->template('index/list_news');
				}
				
			;
			break;
			case 'contact'://联系我们
			;
			break;

		}
		
	}

	
	
	
	
	
	
	
	
	
	
	
	/**
	 * 广告管理开始   
	 **/
	public function doPageAdlist() {
		
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_cms_ad')." where 1=1 ";
		if($_GPC['ad_title']){
			$sql=$sql." and ad_title like '%".$_GPC['ad_title']."%'";
		}
		$ad_list=pdo_fetchall($sql);
		//分页
		$total=count($ad_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by ad_id desc limit ".$p." , ".$pagesize;
		//分页结束
		$work_Log=pdo_fetchall($sql);


		
        include $this->template('admin/ad/ad_list');
	}
	
	
	//*************** 编辑与添加****************************//
	public function doPageAdedit() {
		global $_W, $_GPC;
		if($_GET['ad_id']){
			$ad=pdo_get('index_cms_ad',array('ad_id'=>$_GET['ad_id']));
		}
		
        include $this->template('admin/ad/ad_edit');
		
		
	}
	//*************** 保存数据****************************//
	public function doPageAdsave(){
		
		global $_W, $_GPC;
		
		$data=$_POST;
		
		$data['last_time']=date('Y-m-d H:i:s');
		if($_POST['ad_id']){
			$res=pdo_update('index_cms_ad',$data,array('ad_id'=>$_POST['ad_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date('Y-m-d H:i:s');
			$res=pdo_insert('index_cms_ad',$data);
		}
		
		if($res){
			message('保存成功!',$this->createWebUrl('adlist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
		//*************** 编辑与添加****************************//
	public function doPageAddel() {
		
		global $_W, $_GPC;
		
		if($_GET['ad_id']){
			$res = pdo_delete('index_cms_ad', array('ad_id' => $_GET['ad_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('adlist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	
	/**
	 * 广告管理结束
	 **/	
	
	
//*************** 文章管理开始****************************//
//*************** 文章开始****************************//	
	public function doPageArticlelist() {
		//这个操作被定义用来呈现 管理中心导航菜单
		
		global $_W, $_GPC;
        // 分类
		$categorys=pdo_getall('index_cms_category');
		
		
		//文章列表
		$sql="select * from ".tablename('index_cms_article')." where 1=1 ";
		if($_GPC['cat_id']){
			$sql=$sql." and article_cat=".$_GPC['cat_id'];
		}
		if($_GPC['article_title']){
			$sql=$sql." and article_title like '%".$_GPC['article_title']."%'";
		}
		if($_GPC['add_time']){
			$sql=$sql." and add_time>= '".date("Y-m-d",strtotime("-$_GPC[add_time] days"))."'";
		}
		
		$article_list=pdo_fetchall($sql);
		//分页
		$total=count($article_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by article_sort desc limit ".$p." , ".$pagesize;
		//分页结束
		$article_list=pdo_fetchall($sql);
		foreach($article_list as &$article){
			$article['article_cat']=pdo_getcolumn('index_cms_category', array('cat_id' => $article['article_cat']), 'cat_name');
		}
		
		
        include $this->template('admin/article/article_list');
	}	
		//*************** 编辑与添加****************************//
	public function doPageArticleedit() {
		global $_W, $_GPC;
		// 分类
		$categorys=pdo_getall('index_cms_category');
		
		if($_GET['article_id']){
			$article=pdo_get('index_cms_article',array('article_id'=>$_GET['article_id']));
		}
		
        include $this->template('admin/article/article_edit');
		
		
	}
	//*************** 保存数据****************************//
	public function doPageArticlesave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_POST['article_id']){
			$res=pdo_update('index_cms_article',$data,array('article_id'=>$data['article_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_cms_article',$data);
		}
		
		if($res){
			message('操作成功!',$this->createWebUrl('articlelist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
		//*****删除*************//
	public function doPageArticledel() {
		global $_W, $_GPC;
		if($_GET['article_id']){
			$res = pdo_delete('index_cms_article', array('article_id' => $_GET['article_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('articlelist',array('module_type'=>'system_welcome')));
		}else{
			message('删除成功!','referer','error');
		}
	}
	
	
	
	
	
//*************** 文章管理结束****************************//
//*************** 文章分类开始****************************
	public function doPageCategory() {
		//这个操作被定义用来呈现 管理中心导航菜单
		
		global $_W, $_GPC;
        // 将渲染模块目录下的web端的模板文件
		//$work_Log=pdo_getall('zh_lvsh_riji',array('uniacid'=>$_W['uniacid']));
		$sql="select * from ".tablename('index_cms_category');
		$catagory_list=pdo_fetchall($sql);
		//分页
		$total=count($catagory_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by cat_sort desc limit ".$p." , ".$pagesize;
		//分页结束
		$catagory_list=pdo_fetchall($sql);


		
        include $this->template('admin/article/category_list');
	}	
	//*************** 编辑与添加****************************//
	public function doPageCategoryedit() {
		global $_W, $_GPC;
		// 分类
		if($_GET['cat_id']){
			$category=pdo_get('index_cms_category',array('cat_id'=>$_GET['cat_id']));
			$$category['true_image']=tomedia($category['cat_logo']);
		}
		
		include $this->template('admin/article/category_edit');
	
	
	}
	//*************** 保存数据****************************//
	public function doPageCategorysave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_POST['cat_id']){
			$res=pdo_update('index_cms_category',$data,array('cat_id'=>$data['cat_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_cms_category',$data);
		}
	
		if($res){
			message('操作成功!',$this->createWebUrl('category',array('module_type'=>'system_welcome')));
		}else{
			message('删除成功!','referer','error');
		}
	}
	//*****删除*************//
	public function doPageCategorydel() {
		global $_W, $_GPC;
		if($_GET['cat_id']){
			if(pdo_get('index_cms_article',array('article_cat'=>$_GET['cat_id']))){
				$msg='此分类下有所属文章,不可删除';
			}else{
				$res = pdo_delete('index_cms_category', array('cat_id' => $_GET['cat_id']));
				$msg='删除成功!';
			}
		}
		if($res){
			message($msg,$this->createWebUrl('category',array('module_type'=>'system_welcome')));
		}else{
			$msg='参数有误,删除失败';
			message($msg,'referer','error');
		}
	}
	
	
	
	//*************** 文章分类结束****************************//
	//*************** 文章公告开始****************************//
	
	
	public function doPageNoticelist() {

		global $_W, $_GPC;
		$sql="select * from ".tablename('index_cms_notice')." where 1=1 ";
		if($_GPC['notice_title']){
			$sql=$sql." and notice_title like '%".$_GPC['notice_title']."%'";
		}
		if($_GPC['add_time']){
			$sql=$sql." and add_time>= '".date("Y-m-d",strtotime("-$_GPC[add_time] days"))."'";
		}
		$notice_list=pdo_fetchall($sql);
		//分页
		$total=count($notice_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by notice_sort desc limit ".$p." , ".$pagesize;
		//分页结束
		$notice_list=pdo_fetchall($sql);
		
		
		include $this->template('admin/notice/notice_list');
	}
	
	//*************** 编辑与添加****************************//
	public function doPageNoticeedit() {
		global $_W, $_GPC;
	
		if($_GET['notice_id']){
			$notice=pdo_get('index_cms_notice',array('notice_id'=>$_GET['notice_id']));
		}
		
		include $this->template('admin/notice/notice_edit');
	
	
	}
	//*************** 保存数据****************************//
	public function doPageNoticesave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_POST['notice_id']){
			$res=pdo_update('index_cms_notice',$data,array('notice_id'=>$data['notice_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_cms_notice',$data);
		}
	
		if($res){
			message('操作成功!',$this->createWebUrl('noticelist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	//*****删除*************//
	public function doPageNoticedel() {
		global $_W, $_GPC;
		if($_GET['notice_id']){
			$res = pdo_delete('index_cms_notice', array('notice_id' => $_GET['notice_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('noticelist',array('module_type'=>'system_welcome')));
		}else{
			message('参数有误,删除失败!','referer','error');
		}
	}
	
	
	
	
	//*************** 文章分类结束****************************//
	
	
	//*************** 产品管理开始****************************//
	
	
	
	public function doPageProductlist() {

		global $_W, $_GPC;
		$sql="select * from ".tablename('index_mis_product')." where 1=1 ";
		if($_GPC['product_name']){
			$sql=$sql." and product_name like '%".$_GPC['product_name']."%'";
		}
		if($_GPC['add_time']){
			$sql=$sql." and add_time>= '".date("Y-m-d",strtotime("-$_GPC[add_time] days"))."'";
		}
		$product_list=pdo_fetchall($sql);
		//分页
		$total=count($product_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by product_id desc limit ".$p." , ".$pagesize;
		//分页结束
		$product_list=pdo_fetchall($sql);
		foreach($product_list as &$pro){
			$pro['product_thumb']=tomedia($pro['product_thumb']);
		}
		
		
		include $this->template('admin/product/product_list');
	}
	
	//*************** 编辑与添加****************************//
	public function doPageProductedit() {
		global $_W, $_GPC;
	
		if($_GET['product_id']){
			$product=pdo_get('index_mis_product',array('product_id'=>$_GET['product_id']));
		}
		
		include $this->template('admin/product/product_edit');
	
	
	}
	//*************** 保存数据****************************//
	public function doPageProductsave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_POST['product_id']){
			$res=pdo_update('index_mis_product',$data,array('product_id'=>$data['product_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_mis_product',$data);
		}
	
		if($res){
			message('操作成功!',$this->createWebUrl('productlist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	//*****删除*************//
	public function doPageProductdel() {
		global $_W, $_GPC;
		if($_GET['product_id']){
			$res = pdo_delete('index_mis_product', array('product_id' => $_GET['product_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('productlist',array('module_type'=>'system_welcome')));
		}else{
			message('参数有误,删除失败!','referer','error');
		}
	}
	
	
	

	//*************** 产品结束****************************//
	
	
	//*************** 案例开始****************************//
	
	
	
	public function doPageCaselist() {
	
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_mis_case')." where 1=1 ";
		if($_GPC['case_name']){
			$sql=$sql." and case_name like '%".$_GPC['case_name']."%'";
		}
		if($_GPC['add_time']){
			$sql=$sql." and add_time>= '".date("Y-m-d",strtotime("-$_GPC[add_time] days"))."'";
		}
		$case_list=pdo_fetchall($sql);
		//分页
		$total=count($case_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by case_id desc limit ".$p." , ".$pagesize;
		//分页结束
		$case_list=pdo_fetchall($sql);
		foreach($case_list as &$pro){
			$pro['case_thumb']=tomedia($pro['case_thumb']);
		}
	
		
		include $this->template('admin/case/case_list');
	}
	
	//*************** 编辑与添加****************************//
	public function doPageCaseedit() {
		global $_W, $_GPC;
	
		if($_GET['case_id']){
			$case=pdo_get('index_mis_case',array('case_id'=>$_GET['case_id']));
		}
		
		include $this->template('admin/case/case_edit');
	
	
	}
	//*************** 保存数据****************************//
	public function doPageCasesave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_POST['case_id']){
			$res=pdo_update('index_mis_case',$data,array('case_id'=>$data['case_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_mis_case',$data);
		}
	
		if($res){
			message('操作成功!',$this->createWebUrl('caselist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	//*****删除*************//
	public function doPageCasedel() {
		global $_W, $_GPC;
		if($_GET['case_id']){
			$res = pdo_delete('index_mis_case', array('case_id' => $_GET['case_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('caselist',array('module_type'=>'system_welcome')));
		}else{
			message('参数有误,删除失败!','referer','error');
		}
	}
	
	
	//*************** 案例结束****************************//
	
	
	//*************** 招聘开始****************************//
	
	
	
	
	public function doPageRecruitlist() {
	
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_mis_recruit')." where 1=1 ";
		if($_GPC['recruit_title']){
			$sql=$sql." and recruit_title like '%".$_GPC['recruit_title']."%'";
		}
		if($_GPC['add_time']){
			$sql=$sql." and add_time>= '".date("Y-m-d",strtotime("-$_GPC[add_time] days"))."'";
		}
		$recruit_list=pdo_fetchall($sql);
		//分页
		$total=count($recruit_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by recruit_id desc limit ".$p." , ".$pagesize;
		//分页结束
		$recruit_list=pdo_fetchall($sql);
		foreach($recruit_list as &$pro){
			$pro['recruit_thumb']=tomedia($pro['recruit_thumb']);
		}
	
		
		include $this->template('admin/recruit/recruit_list');
	}
	
	//*************** 编辑与添加****************************//
	public function doPageRecruitedit() {
		global $_W, $_GPC;
	
		if($_GET['recruit_id']){
			$recruit=pdo_get('index_mis_recruit',array('recruit_id'=>$_GET['recruit_id']));
		}
		
		include $this->template('admin/recruit/recruit_edit');
	
	
	}
	//*************** 保存数据****************************//
	public function doPageRecruitsave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_POST['recruit_id']){
			$res=pdo_update('index_mis_recruit',$data,array('recruit_id'=>$data['recruit_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_mis_recruit',$data);
		}
	
		if($res){
			message('操作成功!',$this->createWebUrl('recruitlist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	//*****删除*************//
	public function doPageRecruitdel() {
		global $_W, $_GPC;
		if($_GET['recruit_id']){
			$res = pdo_delete('index_mis_recruit', array('recruit_id' => $_GET['recruit_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('recruitlist',array('module_type'=>'system_welcome')));
		}else{
			message('参数有误,删除失败!','referer','error');
		}
	}
	
	
	

	//*************** 招聘结束****************************//
	
	
	//*************** 系统配置开始****************************//
	//*************** 系统配置公司信息开始****************************//
	public function doPageConfigenterprise(){
		global $_W, $_GPC;
		
		$config_group='basic';
		
		if(empty($_GPC['site_code'])){
			$site_code=$_SERVER['HTTP_HOST'];//域名
		}else{
			$site_code=$_GPC['site_code'];//域名
		}
		$list=pdo_getall('index_sys_config',array('config_group'=>$config_group,'status'=>1,'site_code'=>$site_code));
		$config_row=array();
		foreach ($list as &$conf){
			$config_row[$conf['config_code']]=$conf['config_value'];
		}
		
		include $this->template('admin/config/config_index');
	}
	
	/**
	 * @name  doPageConfigsave()
	 * @desc  保存系统配置列表数据
	 * @author xiaolonglong
	 * @updatetime  2018年4月26日
	 * @version 1.0.0
	 */
	public function doPageConfigsave(){
		global $_W, $_GPC;
		$config_list=$_POST;
		foreach ($config_list as $key=>$value ){
			$conf['uid']=$_W['uid'];
			$conf['config_value']=$value;
			$conf['last_time']=date('Y-m-d H:i:s');
			
			$has=pdo_get('index_sys_config',array('config_code'=>$key,'site_code'=>$_GPC['site_code']));
			if($has){
				$res=pdo_update('index_sys_config',$conf,array('config_code'=>$key,'site_code'=>$_GPC['site_code']));
			}else{
				$conf=array(
						'config_code'=>$key,
						'config_type'=>'text',
						'config_group'=>$_GPC['config_group'],
						'site_code'=>$_GPC['site_code'],
						'status'=>1,
						'uid'=>$_W['uid'],
						'config_value'=>$value,
						'add_time'=>date('Y-m-d H:i:s'),
						'last_time'=>date('Y-m-d H:i:s')
				);
				$res=pdo_insert('index_sys_config',$conf);
			}
		}
		if($res){
			message('修改成功!','referer','success');
		}else{
			message('参数有误,修改失败!','referer','error');
		}
	}
	
	public function doPageConfigwebset(){
		global $_W, $_GPC;
	
		$config_group='basic';
		
		$list=pdo_getall('index_sys_config',array('config_group'=>$config_group,'status'=>1));
		$config_row=array();
		foreach ($list as &$conf){
			$config_row[$conf['config_code']]=$conf['config_value'];
		}
	
		
		include $this->template('admin/config/config_index');
	}
	
	
	
	
	//*************** 公司信息结束****************************//
	//*************** 网站信息开始****************************//
	
	
	
	public function doPageGuestbook() {
	
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_cms_guestbook')." where 1=1 ";
		if($_GPC['guestbook_name']){
			$sql=$sql." and guestbook_name like '%".$_GPC['guestbook_name']."%'";
		}
		if($_GPC['add_time']){
			$sql=$sql." and add_time>= '".date("Y-m-d",strtotime("-$_GPC[add_time] days"))."'";
		}
		$guestbook_list=pdo_fetchall($sql);
		//分页
		$total=count($guestbook_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by guestbook_id desc limit ".$p." , ".$pagesize;
		//分页结束
		$guestbook_list=pdo_fetchall($sql);
	
		
		include $this->template('admin/guestbook/guestbook_list');
	}
	
	
	
	//*************** 网站信息结束****************************//
	//*************** 小程序banner开始 20180517****************************//
	
	
	public function doPageSitelist() {
	
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_banner_site');
		$site_list=pdo_fetchall($sql);
		include $this->template('admin/banner/site_list');
	}
	//*************** 编辑与添加****************************//
	public function doPageSiteedit() {
		global $_W, $_GPC;
	
		if($_GET['site_id']){
			$site=pdo_get('index_banner_site',array('site_id'=>$_GET['site_id']));
		}
		include $this->template('admin/banner/site_edit');
	
	}
	//*************** 保存数据****************************//
	public function doPageSitesave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_GPC['site_id']){
			$res=pdo_update('index_banner_site',$data,array('site_id'=>$_GPC['site_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_banner_site',$data);
		}
	
		if($res){
			message('操作成功!',$this->createWebUrl('sitelist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	
	
	
	public function doPageBannerlist() {
	
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_banner')." where 1=1 ";
		if($_GPC['banner_title']){
			$sql=$sql." and banner_title like '%".$_GPC['banner_title']."%'";
		}
		if($_GPC['add_time']){
			$sql=$sql." and add_time>= '".date("Y-m-d",strtotime("-$_GPC[add_time] days"))."'";
		}
		$banner_list=pdo_fetchall($sql);
		//分页
		$total=count($banner_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by banner_sort desc limit ".$p." , ".$pagesize;
		//分页结束
		$banner_list=pdo_fetchall($sql);
		foreach($banner_list as &$pro){
			$pro['banner_thumb']=tomedia($pro['banner_thumb']);
			$pro['banner_site']=pdo_getcolumn('index_banner_site', array('site_id' => $pro['banner_site']), 'site_title');
		}
	
		
		include $this->template('admin/banner/banner_list');
	}
	
	//*************** 编辑与添加****************************//
	public function doPageBanneredit() {
		global $_W, $_GPC;
		$sites=pdo_getall('index_banner_site');
		if($_GET['banner_id']){
			$banner=pdo_get('index_banner',array('banner_id'=>$_GET['banner_id']));
		}
		
		include $this->template('admin/banner/banner_edit');
	
	}
	//*************** 保存数据****************************//
	public function doPageBannersave(){
		global $_W, $_GPC;
		$data=$_POST;
		$data['last_time']=date("Y-m-d H:i:s");
		$data['status']=1;
		if($_POST['banner_id']){
			$res=pdo_update('index_banner',$data,array('banner_id'=>$data['banner_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date("Y-m-d H:i:s");
			$res=pdo_insert('index_banner',$data);
		}
	
		if($res){
			message('操作成功!',$this->createWebUrl('bannerlist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	//*****删除*************//
	public function doPageBannerdel() {
		global $_W, $_GPC;
		if($_GET['banner_id']){
			$res = pdo_delete('index_banner', array('banner_id' => $_GET['banner_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('bannerlist',array('module_type'=>'system_welcome')));
		}else{
			message('参数有误,删除失败!','referer','error');
		}
	}
	
	
	/**
	 * 友情链接管理开始20180523
	 **/
	public function doPageLinklist() {
	
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_mis_friendlink')." where 1=1 ";
		if($_GPC['link_name']){
			$sql=$sql." and link_name like '%".$_GPC['link_name']."%'";
		}
		$link_list=pdo_fetchall($sql);
		//分页
		$total=count($link_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by link_id desc limit ".$p." , ".$pagesize;
		//分页结束
		$work_Log=pdo_fetchall($sql);
	
	
	
		include $this->template('admin/link/link_list');
	}
	
	
	//*************** 编辑与添加****************************//
	public function doPageLinkedit() {
		global $_W, $_GPC;
		if($_GET['link_id']){
			$link=pdo_get('index_mis_friendlink',array('link_id'=>$_GET['link_id']));
		}
	
		include $this->template('admin/link/link_edit');
	
	
	}
	//*************** 保存数据****************************//
	public function doPageLinksave(){
	
		global $_W, $_GPC;
	
		$data=$_POST;
	
		$data['last_time']=date('Y-m-d H:i:s');
		if($_POST['link_id']){
			$res=pdo_update('index_mis_friendlink',$data,array('link_id'=>$_POST['link_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date('Y-m-d H:i:s');
			$res=pdo_insert('index_mis_friendlink',$data);
		}
	
		if($res){
			message('保存成功!',$this->createWebUrl('linklist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	//*************** 编辑与添加****************************//
	public function doPageLinkdel() {
	
		global $_W, $_GPC;
	
		if($_GET['link_id']){
			$res = pdo_delete('index_mis_friendlink', array('link_id' => $_GET['link_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('linklist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	
	/**
	 * 友链管理结束
	 **/
	/**
	 * 站点管理开始20180525
	 **/
	public function doPageSitlist() {
	
		global $_W, $_GPC;
		$sql="select * from ".tablename('index_sys_site')." where 1=1 ";
		if($_GPC['site_cust']){
			$sql=$sql." and site_cust like '%".$_GPC['site_cust']."%'";
		}
		$site_list=pdo_fetchall($sql);
		//分页
		$total=count($site_list);
		$pageindex=max($_GPC['page'],1);
		$pagesize=10;
		$pager=pagination($total,$pageindex,$pagesize);
		$p=($pageindex-1)*$pagesize;
		$sql.=" order by site_id desc limit ".$p." , ".$pagesize;
		//分页结束
		$work_Log=pdo_fetchall($sql);
	
	
	
		include $this->template('admin/site/site_list');
	}
	
	
	//*************** 编辑与添加****************************//
	public function doPageSitdit() {
		global $_W, $_GPC;
		if($_GET['site_id']){
			$site=pdo_get('index_sys_site',array('site_id'=>$_GET['site_id']));
		}
	
		include $this->template('admin/site/site_edit');
	
	
	}
	//*************** 保存数据****************************//
	public function doPageSitsave(){
	
		global $_W, $_GPC;
	
		$data=$_POST;
	
		$data['last_time']=date('Y-m-d H:i:s');
		if($_POST['site_id']){
			$res=pdo_update('index_sys_site',$data,array('site_id'=>$_POST['site_id']));
		}else{
			$data['uid']=$_W['uid'];
			$data['add_time']=date('Y-m-d H:i:s');
			$res=pdo_insert('index_sys_site',$data);
		}
	
		if($res){
			message('保存成功!',$this->createWebUrl('sitlist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
	//*************** 编辑与添加****************************//
	public function doPageSitdel() {
	
		global $_W, $_GPC;
	
		if($_GET['site_id']){
			$res = pdo_delete('index_sys_site', array('site_id' => $_GET['site_id']));
		}
		if($res){
			message('删除成功!',$this->createWebUrl('sitlist',array('module_type'=>'system_welcome')));
		}else{
			message('操作失败','referer','error');
		}
	}
}